<template>
    <div>
     <div class="mui-scroll-wrapper  mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
    <div class="mui-scroll" >
        <a :class="['mui-control-item',item.id==0?'mui-active':'' ]" v-for="item in cates" :key="item.id" @click="getImg(item.id)">
            {{item.title}}
        </a>
    </div>
</div>
<ul class="vimg-ul">
  <router-link v-for="item in list" :key="item.id" :to="'/home/vtits'+item.id" tag="li">
    <img v-lazy="item.img_url">
    <div class="vimg-tit">
        <h3>{{item.title}}</h3>
        <h3>{{item.zhaiyao}}</h3>
    </div>
  </router-link>
</ul>
    </div>
</template>
<script>
// import mui from '../../lib/mui/js/mui.min.js'
export default {
    data() {
        return {
            cates:[],
            list:[]
        }
    },
    created(){
      this.getAll(),
      this.getImg(0)
    },
	mounted:function () {
    this.mui('.mui-scroll-wrapper').scroll({
	deceleration: 0.0005, //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
	 scrollX: true,
	 indicators:true,
	 scrollY: false
});
	},
	methods:{
        getAll(){
            this.$axios.get('api/getimgcategory').then(res=>{
                // console.log(res)
                if(res.data.status===0){
                   res.data.message.unshift({title:"全部",id:0});
                   this.cates=res.data.message;
                }
            })
        },
        getImg(imgid){
            this.$axios.get('api/getimages/'+imgid).then(res=>{
                if(res.data.status===0){
                    this.list=res.data.message;
                }
            })
      
        }
    }
}
</script>
<style lang="scss" scoped>
 * { touch-action: pan-y; } 
 .mui-slider-indicator.mui-segmented-control {
    position: fixed;
    bottom: auto;
    top: 44px;
    background-color: #fff;
}
.vimg-ul{
    list-style: none;
    text-align: center;
    margin: 0;
    padding: 10px 10px 0px;
    box-sizing: border-box;
    margin-top: 40px;
    li{
    position: relative;
    }

    img{
        width: 100%;
        vertical-align: middle;
         padding-bottom: 10px;
        box-sizing: border-box;
    }
    img[lazy=loading] {
  width: 40px;
  height: 300px;
  margin: auto;
}
.vimg-tit{
position: absolute;
bottom: 10px;
color: #fff;
background-color: rgba(0, 0, 0, 0.5);
text-align: left;
max-height: 100px;
  text-overflow:ellipsis; 
h3{
    max-height: 100px;
    font-size: 12px;
    color: #fff;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
  line-height: 16px;
  padding: 0px 3px;
}
}
}
</style>
